{extend name="public/base"/}
{block name="style"}
{/block}
{block name="content"}
<div class="out-list">
    <div class="layui-row">
        <div class="layui-inline">
            <input type="text" class="layui-input" autocomplete="off" autofocus="autofocus" id="order-sn" placeholder="订单号/追踪号">
        </div>
        <div class="layui-inline">
            <input style="width: 180px !important;" type="number" class="layui-input" autocomplete="off" id="order-weight" placeholder="订单重量">
        </div>
        <div class="layui-inline">
            <button type="button" class="layui-btn layui-btn-sm layui-btn-normal btn-search"><i class="layui-icon layui-icon-search"></i></button>
        </div>
    </div>
    <div class="data">
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
layui.use(['layer', 'jquery', 'longli'], function()
{
    var layer = layui.layer
        , $ = layui.jquery;

    $(".btn-search").click(function()
    {
        var $s = $("#order-sn")
            , sn = $s.val().trim()
            , $w = $("#order-weight")
            , weight = $w.val() * 1;
        if(!sn)
        {
            layer.msg('请输入订单号', {icon: 5, time: 1500});
            return false;
        }
        if(isNaN(weight) || weight <= 0)
        {
            layer.msg('请输入正确的订单重量', {icon: 5, time: 1500});
            $w.val('').focus();
            return false;
        }
        $.post("{:url('weight')}", {sn, weight}).done(function(response)
        {
            $s.val('').focus();
            $w.val('');
            var icon = response.code == 1 ? 6 : 5
            layer.msg(response.msg, {icon: icon, time: 1500});
            if(response.data.type) layui.longli.playMP3(response.data.type);
            if(response.data.html) $(".data").html(response.data.html);
        });
    });
    $("#order-sn").keydown(function(event)
    {
        if(event.keyCode != 13) return;
        $("#order-weight").focus();
    });
    $("#order-weight").keydown(function(event)
    {
        if(event.keyCode != 13) return;
        $(".btn-search").click();
    });
});
</script>
{/block}